CREATE TABLE [dbo].[tb_Instancias]
(
[IdInstancia] [int] NOT NULL IDENTITY(4000, 1),
[IdSubProyecto] [int] NOT NULL,
[CodigoRefepec] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IdModalidadCertificacion] [int] NULL,
[IdTurno] [int] NULL,
[IdSubOrganizacion] [int] NULL,
[IdLocalidad] [int] NOT NULL,
[FechaDesde] [datetime] NULL,
[FechaHasta] [datetime] NULL,
[Norma] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IdSubOrganizacionEmisora] [int] NULL,
[NTUser] [int] NOT NULL CONSTRAINT [DF_tb_Instancias_NTUser] DEFAULT ([dbo].[sp_usuario](suser_sname())),
[FechaRegistro] [datetime] NOT NULL CONSTRAINT [DF_tb_Instancias_FechaRegistro] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Instancias] ADD CONSTRAINT [PK_tb_Instancias] PRIMARY KEY CLUSTERED  ([IdInstancia]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Instancias] WITH NOCHECK ADD CONSTRAINT [FK_tb_Instancias_tb_ModalidadesCertificaciones] FOREIGN KEY ([IdModalidadCertificacion]) REFERENCES [dbo].[tb_ModalidadesCertificaciones] ([IdModalidadCertificacion])
GO
ALTER TABLE [dbo].[tb_Instancias] WITH NOCHECK ADD CONSTRAINT [FK_tb_Instancias_tb_SubOrganizaciones] FOREIGN KEY ([IdSubOrganizacion]) REFERENCES [dbo].[tb_SubOrganizaciones] ([idSubOrganizacion])
GO
ALTER TABLE [dbo].[tb_Instancias] WITH NOCHECK ADD CONSTRAINT [FK_tb_Instancias_tb_SubProyectos] FOREIGN KEY ([IdSubProyecto]) REFERENCES [dbo].[tb_SubProyectos] ([IdSubProyecto])
GO
ALTER TABLE [dbo].[tb_Instancias] WITH NOCHECK ADD CONSTRAINT [FK_tb_Instancias_tb_Turnos] FOREIGN KEY ([IdTurno]) REFERENCES [dbo].[tb_Turnos] ([idTurno])
GO
